import requests
import traceback
import time
import selenium
from selenium import webdriver


def get_url():
    url = 'https://www.eeagd.edu.cn/zkbk/login/login.jsp'
    driver = webdriver.Chrome()
    driver.get(url)
    return driver


dr = get_url()
n = 1
while True:
    time.sleep(30)
    print(f"第{n}次刷新~")
    try:
        dr.find_element_by_xpath('//*[@id="imgVcode"]')
    except Exception:
        dr.refresh()
        n += 1
    else:
        time.sleep(10000)
# try:
#     rep = requests.get(url)
# except Exception:
#     traceback.print_exc()
# else:
#     print(rep.status_code)
#     print(rep.text)
# time.sleep(10)
